Base solution for your next web application

Activities of "hans abelshausen"

Yes, I have copied your code, here it is: (in my loginresult.User there is an error: internal error in method "Abp.Authorization.Users.AbpUserManager'3#AbpLoginResult[TTenant, TRole, TUser].get_user()")

using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Abp.Authorization.Users;
using Abp.UI;
using Abp.Web.Mvc.Models;
using Microsoft.AspNet.Identity;
using Microsoft.Owin.Security;
using Test.Security.Users;
using Test.Web.Models.Account;


namespace Test.Web.Controllers
{
    public class AccountController : TestControllerBase
    {
        private readonly UserManager _userManager;

        private IAuthenticationManager AuthenticationManager
        {
            get
            {
                return HttpContext.GetOwinContext().Authentication;
            }
        }

        public AccountController(UserManager userManager)
        {
            _userManager = userManager;
        }

        public ActionResult Login(string returnUrl = "")
        {
            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }

            ViewBag.ReturnUrl = returnUrl;

            return View();
        }

        [HttpPost]
        public async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "")
        {
            if (!ModelState.IsValid)
            {
                throw new UserFriendlyException("Your form is invalid!");
            }

            var loginResult = await _userManager.LoginAsync(
                loginModel.UsernameOrEmailAddress,
                loginModel.Password,
                loginModel.TenancyName
                );

            
            switch (loginResult.Result)
            {
                case AbpLoginResultType.Success:
                    break;
                case AbpLoginResultType.InvalidUserNameOrEmailAddress:
                case AbpLoginResultType.InvalidPassword:
                    throw new UserFriendlyException("Invalid user name or password!");
                case AbpLoginResultType.InvalidTenancyName:
                    throw new UserFriendlyException("No tenant with name: " + loginModel.TenancyName);
                case AbpLoginResultType.TenantIsNotActive:
                    throw new UserFriendlyException("Tenant is not active: " + loginModel.TenancyName);
                case AbpLoginResultType.UserIsNotActive:
                    throw new UserFriendlyException("User is not active: " + loginModel.UsernameOrEmailAddress);
                case AbpLoginResultType.UserEmailIsNotConfirmed:
                    throw new UserFriendlyException("Your email address is not confirmed!");
                default: //Can not fall to default for now. But other result types can be added in the future and we may forget to handle it
                    throw new UserFriendlyException("Unknown problem with login: " + loginResult.Result);
            }

            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = loginModel.RememberMe }, loginResult.Identity);

            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }
            
            return Json(new MvcAjaxResponse 
            { 
                TargetUrl = returnUrl
            });
            //return Json(new MvcAjaxResponse 
            //{ 
            //    TargetUrl = returnUrl
            //    //TargetUrl = "/#/"
            //});
        }

        public ActionResult Logout()
        {
            AuthenticationManager.SignOut();
            return RedirectToAction("Login");
        }
    }
}

It seems user is not logged in, but I don't know what is different in my Project... Here is the log file:

DEBUG 2015-06-08 11:16:56,063 [1 ] Abp.Localization.LocalizationManager - Initializing 4 localization sources. DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Abp DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpZero DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpWeb DEBUG 2015-06-08 11:16:57,992 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Test WARN 2015-06-08 11:16:58,315 [10 ] Default - Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) WARN 2015-06-08 11:17:15,594 [12 ] Default - Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext)

I'm using Abp 0.6.2.0 Abp Zero 0.6.0.0

Yes, I have copied the code of your sample Project and the login page is shown, then I took username admin and your Password. In Accountcontroller loginResult is success but this code is never reached:

[AbpMvcAuthorize]
    public class HomeController : MyProjectControllerBase
    {
        public ActionResult Index()
        {
            return View("~/App/Main/views/layout/layout.cshtml"); 
        }
    }

Hi, do you have an answer, why Redirect is not working as expected:

return Json(new MvcAjaxResponse { TargetUrl = returnUrl });

in your example, everything works fine, in my own project, if I log in, the following URL is shown instead of the correct one: this is the Login URL: <a class="postlink" href="http://localhost:6234/Account/Login?ReturnUrl=%2F">http://localhost:6234/Account/Login?ReturnUrl=%2F</a> and after correct log in: <a class="postlink" href="http://localhost:6234/Account/Login?ReturnUrl=%2F">http://localhost:6234/Account/Login?ReturnUrl=%2F</a> exactly the same... if I link to Google it works...

Hi, I tried to update Abp to the newest Version, but now, in Initialize method of the webmodule following error is shown: Can't create component 'Abp.Auditing.AuditingInterceptor' as it has dependencies to be satisfied.

'Abp.Auditing.AuditingInterceptor' is waiting for the following dependencies:

  • Service 'Abp.Auditing.IAuditingStore' which was not registered.

Which dependency is missing?

Update: I put Configuration.Localization.Sources.Add(IocManager.Resolve<DbLocalizationSource>()); in the PostInitialize function and now following error occured in the WebViewPageBase.cs class: Can not find a source with name: "Test"

public abstract class TestWebViewPageBase : TestWebViewPageBase<dynamic>
    {

    }

    public abstract class TestWebViewPageBase<TModel> : AbpWebViewPage<TModel>
    {
        protected TestWebViewPageBase()
        {
           LocalizationSourceName = TestConsts.LocalizationSourceName;
        }
    }

I use a dblocalizationsource and now, if I put the code:

Configuration.Localization.Sources.Add(
                  IocManager.Resolve<DbLocalizationSource>()
                  );

in the PreInitialize or in the Initialize function the first error occurs, if I put it in the PostInitialize function the second error is shown. I have updated abp to Version 0.5.13.0, in the other Version everything works fine Thank you

Question

HI! Can you please tell me, which is the start element of the application. Which html is the standard? In a asp.net application there is an aspx page. Thanks in advance. Hans

Question

Hi! Sorry for my perhaps stupid question. I'm trying to host my first boilerplate Project on a 2012 Microsoft Server. Which is the starting class of the app? If I develop a standard asp.net app, there is a aspx page which is my starting point.

It is surely a very simple question for you :-)

Thanks in advance

Showing 31 to 37 of 37 entries